package com.zqxq.lottery.config;

import com.zqxq.lottery.common.constant.HuaYangConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.amqp.core.*;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitMQConfig {
    @Bean
    public DirectExchange defaultExchange() {
        return new DirectExchange(HuaYangConstant.DEFAULT_EXCHANGE, true, false);
    }

    @Bean
    public Queue repeatTradeQueue() {
        Queue queue = new Queue(HuaYangConstant.DEFAULT_REPEAT_TRADE_QUEUE_NAME,true,false,false);
        return queue;
    }

    @Bean
    public Binding  drepeatTradeBinding() {
        return BindingBuilder.bind(repeatTradeQueue()).to(defaultExchange()).with(HuaYangConstant.DEFAULT_REPEAT_TRADE_QUEUE_NAME);
    }

    @Bean
    public Queue deadLetterQueue() {
        Map<String, Object> arguments = new HashMap<>();
        arguments.put("x-dead-letter-exchange", HuaYangConstant.DEFAULT_EXCHANGE);
        arguments.put("x-dead-letter-routing-key", HuaYangConstant.DEFAULT_REPEAT_TRADE_QUEUE_NAME);
        Queue queue = new Queue(HuaYangConstant.DEFAULT_DEAD_LETTER_QUEUE_NAME,true,false,false,arguments);
        System.out.println("arguments :" + queue.getArguments());
        return queue;
    }

    @Bean
    public Binding  deadLetterBinding() {
        return BindingBuilder.bind(deadLetterQueue()).to(defaultExchange()).with(HuaYangConstant.DEFAULT_DEAD_LETTER_QUEUE_NAME);
    }
    @Bean
    public Queue huayangTicketQueue() {
        return new Queue(HuaYangConstant.MQ_HUAYANG_TICKET,true);
    }

    @Bean
    public Binding huayangTicketBinding() {
        return BindingBuilder.bind(huayangTicketQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_HUAYANG_TICKET);
    }


    @Bean
    public Queue huayangOrderBetQueue() {
        return new Queue(HuaYangConstant.MQ_HUAYANG_ORDER_BET);
    }

    @Bean
    public Binding huayangOrderBetBinding() {
        return BindingBuilder.bind(huayangOrderBetQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_HUAYANG_ORDER_BET);
    }

    @Bean
    public Queue sendCouponQueue() {
        return new Queue(HuaYangConstant.MQ_SEND_COUPON);
    }

    @Bean
    public Binding sendCouponBinding() {
        return BindingBuilder.bind(sendCouponQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_SEND_COUPON);
    }

    @Bean
    public Queue sendPushMsg() {
        return new Queue(HuaYangConstant.MQ_PUSH_LOTTERY_RESULT);
    }

    @Bean
    public Binding sendPushBinding() {
        return BindingBuilder.bind(sendCouponQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_PUSH_LOTTERY_RESULT);
    }

    @Bean
    public Queue sendSSQPushMsg() {
        return new Queue(HuaYangConstant.MQ_PUSH_JCZQ_RESULT);
    }

    @Bean
    public Binding sendSSQPushBinding() {
        return BindingBuilder.bind(sendCouponQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_PUSH_JCZQ_RESULT);
    }

    @Bean
    public Queue sendBatchInsertMsg() {
        return new Queue(HuaYangConstant.MQ_BATCH_INSERT_MSG);
    }

    @Bean
    public Binding sendBatchInsertMsgBinding() {
        return BindingBuilder.bind(sendCouponQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_BATCH_INSERT_MSG);
    }
    /*******************************开奖*******************************/
    @Bean
    public Queue openPrizeBetFcQueue() {
        return new Queue(HuaYangConstant.MQ_OPENPRIZE_BET_FC);
    }
    @Bean
    public Binding openPrizeBetFcBinding() {
        return BindingBuilder.bind(openPrizeBetFcQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_OPENPRIZE_BET_FC);
    }
    @Bean
    public Queue openPrizeBetDltQueue() {
        return new Queue(HuaYangConstant.MQ_OPENPRIZE_BET_DLT);
    }
    @Bean
    public Binding openPrizeBetDltBinding() {
        return BindingBuilder.bind(openPrizeBetDltQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_OPENPRIZE_BET_DLT);
    }
    @Bean
    public Queue openPrizeBetQxcQueue() {
        return new Queue(HuaYangConstant.MQ_OPENPRIZE_BET_QXC);
    }
    @Bean
    public Binding openPrizeBetQxcBinding() {
        return BindingBuilder.bind(openPrizeBetQxcQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_OPENPRIZE_BET_QXC);
    }
    @Bean
    public Queue openPrizeBetPlQueue() {
        return new Queue(HuaYangConstant.MQ_OPENPRIZE_BET_PL);
    }
    @Bean
    public Binding openPrizeBetPlBinding() {
        return BindingBuilder.bind(openPrizeBetPlQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_OPENPRIZE_BET_PL);
    }
    @Bean
    public Queue openPrizeBetJczqQueue() {
        return new Queue(HuaYangConstant.MQ_OPENPRIZE_BET_JCZQ);
    }
    @Bean
    public Binding openPrizeBetJczqBinding() {
        return BindingBuilder.bind(openPrizeBetJczqQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_OPENPRIZE_BET_JCZQ);
    }
    /*******************************派奖*******************************/
    @Bean
    public Queue awardBetSsqQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_SSQ);
    }
    @Bean
    public Binding awardBetSsqBinding() {
        return BindingBuilder.bind(awardBetSsqQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_SSQ);
    }
    @Bean
    public Queue awardBetFcQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_FC);
    }
    @Bean
    public Binding awardBetFcBinding() {
        return BindingBuilder.bind(awardBetFcQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_FC);
    }
    @Bean
    public Queue awardBetDltQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_DLT);
    }
    @Bean
    public Binding awardBetDltBinding() {
        return BindingBuilder.bind(awardBetDltQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_DLT);
    }
    @Bean
    public Queue awardBetQxcQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_QXC);
    }
    @Bean
    public Binding awardBetQxcBinding() {
        return BindingBuilder.bind(awardBetQxcQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_QXC);
    }
    @Bean
    public Queue awardBetPlQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_PL);
    }
    @Bean
    public Binding awardBetPlBinding() {
        return BindingBuilder.bind(awardBetPlQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_PL);
    }
    @Bean
    public Queue awardBetJczqQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_JCZQ);
    }
    @Bean
    public Binding awardBetJczqBinding() {
        return BindingBuilder.bind(awardBetJczqQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_JCZQ);
    }

    @Bean
    public Queue awardBetJclqQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_JCLQ);
    }
    @Bean
    public Binding awardBetJclqBinding() {
        return BindingBuilder.bind(awardBetJclqQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_JCLQ);
    }


    @Bean
    public Queue awardBetDjQueue() {
        return new Queue(HuaYangConstant.MQ_AWARD_BET_DJ);
    }
    @Bean
    public Binding awardBetDjBinding() {
        return BindingBuilder.bind(awardBetJczqQueue()).to(defaultExchange()).with(HuaYangConstant.MQ_AWARD_BET_DJ);
    }



}
